<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>文档列表 - 光年(Light Year Admin)后台管理系统模板</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="LightYear,光年,后台模板,后台管理系统,光年HTML模板">
    <meta name="description" content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">
    <meta name="author" content="yinqi">
    <link href="/lib/css/bootstrap.min.css" rel="stylesheet">
    <link href="/lib/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="/lib/css/style.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/lib/layui/css/layui.css" media="all">
</head>

<body>
<div class="container-fluid p-t-15">

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-toolbar clearfix">
                    <form class="pull-right search-bar" method="get" action="#!" role="form">
                        <select class="btn btn-default dropdown-toggle" id="seo_keywords3" name="seo_keywords"  placeholder="请选择类别" >
                            <option value="1">姓名</option>
                            <option value="2">昵称</option>
                            <option value="3">手机号码</option>
                            <option value="4">用户邮箱</option>
                        </select>
                        <div class="input-group">
                            <input id="sname" type="text" class="form-control" placeholder="请输关键字查询">
                            <span class="input-group-btn">
                                <button id="search" class="btn btn-default" type="button">搜索</button>
                            </span>
                        </div>
                    </form>
                </div>
                <input type="hidden" th:value="${mid}" id="mid">
                <!-- <div class="card-body">

                     <div class="table-responsive">
                         <table class="table table-bordered">
                             <thead>
                             <tr>
                                 <th>
                                     <label class="lyear-checkbox checkbox-primary">
                                         <input type="checkbox" id="check-all"><span></span>
                                     </label>
                                 </th>
                                 <th>ID</th>
                                 <th>产品名称</th>
                                 <th>产品单价</th>
                                 <th>库存数量</th>
                                 <th>状态</th>
                                 <th>操作</th>
                             </tr>
                             </thead>
                             <tbody>
                             <tr>
                                 <td>
                                     <label class="lyear-checkbox checkbox-primary">
                                         <input type="checkbox" name="ids[]" value="1"><span></span>
                                     </label>
                                 </td>
                                 <td>1</td>
                                 <td>第01章 天涯思君不可忘</td>
                                 <td>金庸</td>
                                 <td>36</td>
                                 <td><font class="text-success">正常</font></td>
                                 <td>
                                     <div class="btn-group">
                                         <a class="btn btn-xs btn-default" href="#!" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                                         <a class="btn btn-xs btn-default" href="#!" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
                                     </div>
                                 </td>
                             </tr>
                             </tbody>
                         </table>
                     </div>
                     <ul class="pagination">
                         <li class="disabled"><span>«</span></li>
                         <li class="active"><span>1</span></li>
                         <li><a href="#1">2</a></li>
                         <li><a href="#1">3</a></li>
                         <li><a href="#1">4</a></li>
                         <li><a href="#1">5</a></li>
                         <li><a href="#1">6</a></li>
                         <li><a href="#1">7</a></li>
                         <li><a href="#1">8</a></li>
                         <li class="disabled"><span>...</span></li>
                         <li><a href="#!">14452</a></li>
                         <li><a href="#!">14453</a></li>
                         <li><a href="#!">»</a></li>
                     </ul>

                 </div>-->
            </div>
        </div>

    </div>

</div>
<table class="layui-hide" id="demo" lay-filter="test"></table>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑状态及权限</a>
</script>
<div style=""></div>
<script src="/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/html" id="titleTpl">
    {{# if (d.status=== 1) { }}
    正常
    {{# } else if(d.status=== 1) { }}
    冻结
    {{# } else { }}
    删除
    {{# } }}
</script>
<script type="text/html" id="sex1">
    {{# if (d.sex=== 1) { }}
    男
    {{# } else { }}
    女
    {{# } }}
</script>
<script th:inline="none">
    //JavaScript代码区域
    layui.use(['element','jquery','table','layer'], function(){
        var element = layui.element;
        var layer = layui.layer;
        var table = layui.table;
        var $ = layui.jquery;
        //执行一个 table 实例
        table.render({
            elem: '#demo'
            ,height: 420
            ,url: '/user/adminlist' //数据接口 ajax
            //,where条件
            ,page: true //开启分页
            ,toolbar: true //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            ,totalRow: true //开启合计行
            ,cols: [[ //表头
                {title:'序列', type: 'numbers', width:120,fixed: 'left',sort: true}
                ,{field: 'username', title: '会员名称', width:120}
                ,{field: 'nickname', title: '会员昵称', width:120}
                ,{field: 'sex', title: '性别', width:120,toolbar: '#sex1'}
                ,{field: 'email', title: '邮箱', width:120}
                ,{field: 'phone', title: '电话号码', width:160}
                ,{field: 'address', title: '居住地址', width:160}
                ,{field: 'birthday', title: '用户生日', width:160}
                ,{field: 'remark', title: '备注', width:160}
                ,{field: 'role', title: '用户权限', width:160}
                ,{field: 'status', title: '状态', width:160, templet: '#titleTpl'}
                ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#barDemo'}
            ]]
        });
        //监听行工具事件
        table.on('tool(test)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                ,layEvent = obj.event; //获得 lay-event 对应的值
            if(layEvent === 'edit'){
                layer.open({
                    type: 2,
                    content:'/user/modify?uid='+data.id,
                    where:{
                    },
                    area: ['400px', '200px'],
                    end:function (){
                        //重新加载table表格
                        table.reload('demo');
                    }
                })
            }
        });
        $("#search").on('click',function () {
            table.reload('demo',{
                url:'/user/adminlist'//数据接口ajax
                ,where:{//条件查询
                    name:$('#sname').val(),
                    id:$("#seo_keywords3").val()
                }
                ,page:{
                    curr:1
                }
            })
            return false;
        })
    });
</script>
<script type="text/javascript" src="/lib/js/jquery.min.js"></script>
<script type="text/javascript" src="/lib/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/lib/js/main.min.js"></script>
<script type="text/javascript">
    $(function(){
        $('.search-bar .dropdown-menu a').click(function() {
            var field = $(this).data('field') || '';
            $('#search-field').val(field);
            $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
        });
    });
</script>
</body>
</html>